package rohyunji;

public class J19_Callby {

	public static void main(String[] args) 
	{
//		call by value vs call by reference
//		수학값 바꿔치기 
		int a=3,b=5;//기본 자료형
		//참조자료형 
		int [] aa={3};
		int [] bb={5};
		System.out.println(a+" "+aa+""+aa[0]);
		System.out.println("swap실행전a="+a+",b="+b);
		SwapService.swap(a,b);
		System.out.println("swap실행전aa="+aa[0]+",bb="+bb[0]);
		SwapService.swap(aa, bb);
		
		
	}

}

class SwapService
{
	static void swap(int a,int b)
	{
		int temp;
		temp=a;
		a=b;
		b=temp;
		System.out.println("swap실행후a="+a+",b="+b);	
	}
	static void swap(int []aa,int[]bb)
	{
		int temp;
		temp=aa[0];
		aa[0]=bb[0];
		bb[0]=temp;
		System.out.println("swap실행후aa="+aa[0]+",bb="+bb[0]);	
	}

	
}
